﻿using System;

namespace SATBox
{
    /// <summary>
    /// Override for the standard System.Windows.Forms.TextBox. Allows the use of CTRL+A for selection.
    /// Update to base OnLeave event, performs a Trim() on the .Text member.
    /// </summary>
    public class SATextBox : System.Windows.Forms.TextBox
    {
        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
        {
            if (e.Control && (e.KeyCode == System.Windows.Forms.Keys.A))
            {
                this.SelectAll();
                e.SuppressKeyPress = true;
                e.Handled = true;
            }
            else
                base.OnKeyDown(e);
        }

        protected override void OnLeave(EventArgs e)
        {
            this.Text = this.Text.Trim();
            // base.OnLeave(e);
        }
    }
}
